<template>
  <div class="header">
    <div class="header-left">
      <em style="cursor: pointer; position: absolute; left: 0">Tofflon</em>
      <img
        style="
          position: absolute;
          left: 180px;
          margin-left: -20px;
          width: 170px;
          height: 60px;
        "
        class="showimg"
        src="../assets/title_logo2.png"
        @click="toggle(collapsed)"
      />
      <span
        style="
          position: absolute;
          left: 50%;
          margin-left: -50px;
          color: white;
          font-size: 30px;
          top: 6px;
        "
        >物料称量系统</span
      >
    </div>
    <div class="header-right">
      <el-dropdown class="submenu" @command="clickMenu" trigger="click">
        <span>
          <div style="display: flex; align-items: center">
            <i
              class="el-icon-s-check"
              style="
                color: #78daec;
                font-size: 26px;
                height: 60px;
                line-height: 60px;
              "
            ></i>
            <span class="user" style="color: white">操作员</span>
          </div>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="item in menu"
            :key="item.path"
            :command="item"
            >{{ item.label }}</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <div style="display: flex; align-items: center; margin-left: 20px">
        <i
          class="el-icon-s-platform"
          style="
            color: #78daec;
            font-size: 26px;
            height: 60px;
            line-height: 60px;
          "
        ></i>
        <span>HT2364</span>
      </div>
      <div style="display: flex; align-items: center; margin-left: 20px">
        <i
          class="el-icon-time"
          style="
            color: #78daec;
            height: 60px;
            line-height: 60px;
            font-size: 26px;
          "
        ></i>
        <!-- <span><timer /></span> -->
      </div>
    </div>
  </div>
</template>

<script>
// import Timer from "./Timer.vue";
export default {
  data() {
    return {
      username: "操作员",
      host: "HT2479",
      menu: [
        {
          path: "/",
          name: "login",
          label: "退出登录",
        },
      ],
    };
  },
  components: { Timer },
  created() {
    this.username = sessionStorage.getItem("username");
    this.host = sessionStorage.getItem("host");
  },
  methods: {
    clickMenu(item) {
      if (item.name === "login") {
        window.sessionStorage.clear();
        this.$message({
          message: "成功退出登录",
          type: "success",
        });
      }
      const path = item.path;
      this.$router.push(path);
      console.log(item.path);
    },
    // 切换显示
    toggle(showtype) {
      this.collapsed = !showtype;
      this.$root.Bus.$emit("toggle", this.collapsed);
    },
  },
};
</script>
<style>
.el-popper[x-placement^="bottom"] .popper__arrow {
  display: none;
}
.el-popper[x-placement^="bottom"] .popper__arrow::after {
  display: none;
}
</style>
<style lang="scss" scoped>
.el-popper[x-placement^="bottom"] {
  margin-top: -10px;
}
.header {
  display: flex;
  justify-content: space-between;
  background-color: #409eff;
  .header-left {
    background-color: #409eff;
    em {
      color: red;
      font-size: 45px;
    }
  }
  .header-right {
    display: flex;
    justify-content: space-between;
    color: white;
  }
}
</style>
